<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    /*
    在ES5中继承是借助原型对象实现的 
    */
    const Person = { eays: 2, head: 1 }

    /*女人构造函数*/
    function Woman() { }
    //通过原型实现继承
    Woman.prototype = Person
    //让构造函数的prototype.constructor重新指向Woman
    Woman.prototype.constructor = Woman
    //给构造函数的原型上添加方法
    Woman.prototype.baby = function () {
      console.log("宝贝");
    }
    const red = new Woman()
    console.log(red);

    /*男人构造函数*/
    function Man() { }
    //通过原型实现继承
    Man.prototype = Person
    //让构造函数的prototype.constructor重新指向Man
    Man.prototype.constructor = Man
    //给构造函数的原型上添加方法
    Man.prototype.code = function () {
      console.log("代码");
    }
    const pink = new Man()
    console.log(pink);


  </script>
</body>

</html>